package com.example.mask.maskmobilesshop.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.example.mask.maskmobilesshop.entity.Member;
import com.example.mask.maskmobilesshop.mappers.MemberMapper;
import com.example.mask.maskmobilesshop.service.IMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName: MemberServiceImpl
 * @Description: 会员信息
 * @author: Xlh
 * @date 2017年1月16日 下午3:38:06
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService {


    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Member findByName(String loginName) throws Exception {
        try {
            Member member = null;
            List<Member> members = memberMapper.selectList(new EntityWrapper<Member>().eq("mobile", loginName));
            if (members != null && members.size() > 0) {
                member = members.get(0);
            }
            return member;
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }

    @Override
    public Boolean findBySame(String mobile) throws Exception {
        try {
           boolean isTheSame =  memberMapper.findSameMember(mobile);
            return isTheSame;
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }
}
